package com.zlict.admin.controller;

import com.zlict.admin.domain.ProjectPrepare;
import com.zlict.admin.service.IProjectPrepareReasoningService;
import com.zlict.common.annotation.Log;
import com.zlict.common.core.controller.BaseController;
import com.zlict.common.core.domain.AjaxResult;
import com.zlict.common.enums.BusinessType;
import com.zlict.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 项目筹备论证Controller
 * 
 * @author dzw
 */
@RestController
@RequestMapping("/admin/reasoning")
public class ProjectPrepareReasoningController extends BaseController
{
    @Autowired
    private IProjectPrepareReasoningService projectPrepareReasoningService;

    /**
//     * 查询项目筹备论证列表
//     */
//    @PreAuthorize("@ss.hasPermi('admin:reasoning:list')")
//    @GetMapping("/list")
//    public TableDataInfo list(ProjectPrepare ProjectPrepare)
//    {
//        startPage();
//        List<ProjectPrepare> list = projectPrepareReasoningService.selectProjectPrepareList(ProjectPrepare);
//        return getDataTable(list);
//    }
    @PreAuthorize("@ss.hasPermi('admin:reasoning:list')")
    @GetMapping("/list")
    public AjaxResult list(ProjectPrepare ProjectPrepare)
    {
//        startPage();
        List<ProjectPrepare> list = projectPrepareReasoningService.selectProjectPrepareList(ProjectPrepare);
        return success(list);
    }

    /**
     * 导出项目筹备论证列表
     */
    @PreAuthorize("@ss.hasPermi('admin:reasoning:export')")
    @Log(title = "项目筹备论证", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjectPrepare ProjectPrepare)
    {
        List<ProjectPrepare> list = projectPrepareReasoningService.selectProjectPrepareList(ProjectPrepare);
        ExcelUtil<ProjectPrepare> util = new ExcelUtil<>(ProjectPrepare.class);
        util.exportExcel(response, list, "项目筹备论证数据");
    }

    /**
     * 获取项目筹备论证详细信息
     */
    @PreAuthorize("@ss.hasPermi('admin:reasoning:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(projectPrepareReasoningService.selectProjectPrepareById(id));
    }

    /**
     * 新增项目筹备论证
     */
    @PreAuthorize("@ss.hasPermi('admin:reasoning:add')")
    @Log(title = "项目筹备论证", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjectPrepare ProjectPrepare)
    {
        return toAjax(projectPrepareReasoningService.insertProjectPrepare(ProjectPrepare));
    }

    /**
     * 修改项目筹备论证
     */
    @PreAuthorize("@ss.hasPermi('admin:reasoning:edit')")
    @Log(title = "项目筹备论证", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjectPrepare ProjectPrepare)
    {
        return toAjax(projectPrepareReasoningService.updateProjectPrepare(ProjectPrepare));
    }

    /**
     * 删除项目筹备论证
     */
    @PreAuthorize("@ss.hasPermi('admin:reasoning:remove')")
    @Log(title = "项目筹备论证", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(projectPrepareReasoningService.deleteProjectPrepareByIds(ids));
    }
}
